/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhnb
 * Date: 2011-8-1 下午01:58:06
 */
package com.number.app;

import java.io.Serializable;

import Ice.Application;

/**
 * 使用Application实现
 * 
 * @author zhnb
 * 
 */
public class MyApplicationServer extends Application implements Serializable {

    private static final long serialVersionUID = -87723066803692026L;

    @Override
    public int run(String[] args) {
        if (args.length > 0) {
            System.err.println(appName() + ": too many arguments");
            return 1;
        }

        Ice.Properties properties = communicator().getProperties();
        Ice.ObjectAdapter adapter = communicator()
                .createObjectAdapterWithEndpoints(appName(),
                        properties.getProperty("MyApplicationServer.Endpoints"));
        adapter
                .add(
                        new MyApplicationI(),
                        communicator()
                                .stringToIdentity(
                                        properties
                        .getProperty("MyApp.com.number.app.MyApplicationI.uuId")));
        
        adapter.activate();
        
        // show starting completed.
        System.out.println(appName() + " started !");

        communicator().waitForShutdown();
        return 0;
    }

    public static void main(String[] args) {
        MyApplicationServer myApplicationServer = new MyApplicationServer();
        int status = myApplicationServer.main("MyApplicationServer", args,
                "com/number/app/myApp-server.config");
        System.exit(status);
    }

}
